import Toolbar from "@/components/ViewComponents/Toolbar";
import { useTranslation } from "react-i18next";
import { BasicTable, useTable, BasicColumn, FormSchema } from "@/components/Table";
import { message } from "antd";
import { pmtHistoryPage } from "@/api/MedicalExamination/index";

export default function service_payment() {
	const { t } = useTranslation();

	const searchFormSchema: FormSchema[] = [
		{
			label: t("patientBasic.patient_id"),
			field: "patientId",
			component: "Input"
		},
		{
			label: t("patientBasic.full_name"),
			field: "fullName",
			component: "Input"
		},
		{
			label: t("patientBasic.birthyear"),
			field: "birthday",
			component: "Input"
		},
		{
			label: t("felix_ui.department"),
			field: "department",
			component: "Input"
		},
		{
			label: t("felix_ui.card_numb"),
			field: "Card Number",
			component: "Input"
		},
		{
			label: t("patientBasic.pat_address"),
			field: "pat_address",
			component: "Input"
		},
		{
			label: "Place of registration for medical treatment",
			field: "1231",
			component: "Input"
		},
		{
			label: t("felix_ui.rx_diagnosis"),
			field: "diagnosis",
			component: "Input"
		}
	];
	const columns: BasicColumn[] = [
		{
			title: t("felix_ui.patient_ID"),
			dataIndex: "patId"
		},
		{
			title: t("felix_ui.amount"),
			dataIndex: "amount"
		},
		{
			title: t("felix_ui.department"),
			dataIndex: "deptName"
		},
		{
			title: t("felix_ui.order_id"),
			dataIndex: "orderId"
		}
	];

	// const dataSource = [
	// 	{
	// 		med_history: "med_history",
	// 		yes_no: "yes",
	// 		explanation: "explanation"
	// 	}
	// ];
	const [registerTable, { getSelectRowKeys }] = useTable({
		api: pmtHistoryPage,
		columns,
		formConfig: {
			labelWidth: 120,
			schemas: searchFormSchema,
			showActionButtonGroup: true,
			showAdvancedButton: false,
			baseColProps: { span: 6 }
		},
		useSearchForm: true,
		rowSelection: { type: "checkbox" }
	});
	/** Function */
	const handlerAction = (key: string) => {
		switch (key) {
			case "print":
				if (!getSelectRowKeys().length) {
					message.warning("Please select at least one record!");
					return;
				}
				message.success("Function is not open,please wait~");
				break;
		}
	};

	return (
		<div className="page">
			<div className="page-content block">
				<div className="block-label">2.Service payment receipt</div>
				<BasicTable register={registerTable}></BasicTable>
			</div>
			<Toolbar btnList={[{ key: "print", disabled: true }]} action={handlerAction} />
		</div>
	);
}
